home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / dev / basic / Blitz.I.lha / B.I. / Investigator.asc < prev    next >
Text File  |  1999-02-22  |  10KB  |  409 lines

  1. ;Blitz Private Investigator
  2. ;by Curt Esser
  3. ;camge@ix.netcom.com
  4. ;last modified Feb 22 1999
  5. ;PD - do whatever you want with it
  6.  
  7. ;reads Blitz libraries and prints out a list of the commands
  8. ;to a console window, a printer, or disk files
  9. ;can read Deflibs and Amigalibs also
  10.  
  11. ;ReqTools required!
  12.  
  13. WBStartup
  14. NoCli
  15. MaxLen source$=255
  16. MaxLen path$=255
  17. MaxLen svpath$=255
  18. MaxLen svname$=255
  19. MaxLen savepath$=255
  20. z$=Chr$(10)
  21. cxl$="Cancel Library Scan"
  22.  
  23. ;-- read the tooltypes------------------
  24.  
  25. ;set the defaults first:
  26.  
  27. size$="160/20/320/400"
  28. Tsize$="160/20/320/400"
  29. Wclose$="YES"
  30. Tclose$="NO"
  31. close$="/CLOSE/WAIT"
  32. from$="Blitz2:"
  33. saveto$="RAM:"
  34.                                     ;if you don't have BSS
  35.                                     ;substitute the name here:
  36.  
  37. ourname$=ProgName$                  ;get the program's name
  38.  
  39. ok.l=GetIconObject(ourname$)        ;read the tooltypes
  40. If ok
  41.   temp$=FindToolValue("WB")
  42.   If temp$<>"" Then size$=temp$     ;size of wb window
  43.   temp$=FindToolValue("TED")        ;size of Ted window
  44.   If temp$<>"" Then Tsize$=temp$
  45.   temp$=FindToolValue("WBCLOSE")    ;auto close WB window?
  46.   If temp$<>"" Then Wclose$=temp$
  47.   temp$=FindToolValue("TEDCLOSE")   ;auto close on Ted screen?
  48.   If temp$<>"" Then Tclose$=temp$
  49.   temp$=FindToolValue("FROM")       ;default read path
  50.   If temp$<>"" Then from$=temp$
  51.   temp$=FindToolValue("SAVE")       ;default save path
  52.   If temp$<>"" Then saveto$=temp$
  53.   FreeIconObject
  54. EndIf
  55.  
  56. RTEZSetDefaultDirectory 2,saveto$
  57. RTEZSetDefaultDirectory 3,from$
  58.  
  59. onTed.b=0                           ;run on ted's screen?
  60.  
  61. If NumPars
  62.   For i = 1 To NumPars
  63.     If Par$(i)="TED" Then onTed=1
  64.   Next
  65. EndIf
  66.  
  67. Windo$="CON:"                       ;set up parameters for the console window
  68. If onTed
  69.   Windo$+Tsize$
  70. Else
  71.   Windo$+size$
  72. EndIf
  73. Windo$+"/"+ourname$
  74. If onTed
  75.   Windo$+"/SCREENSuperTED1"
  76.   If UCase$(Tclose$)<>"YES"
  77.     Windo$+close$
  78.   EndIf
  79. Else
  80.   If UCase$(Wclose$)<>"YES"
  81.     Windo$+close$
  82.   EndIf
  83. EndIf
  84.  
  85. ; -- test strings for examining the libraries ----------------
  86.  
  87. ok$=Chr$(0)+Chr$(0)+Chr$(3)+Chr$(243)   ;$000003F3 should be at 1st or 4th byte
  88. ok1$=Chr$(0)+Chr$(0)+Chr$(3)+Chr$(233)  ;$000003E9 should come after next 20 bytes
  89. ok2$=Chr$(0)+"Nu"+Chr$(0)               ;find the next lib in deflibs & acidlibs
  90.  
  91. ; --  open a console window for the output -------------------
  92.  
  93. DosBuffLen 0  ;use no buffers for CON: or PRT: for immediate output!
  94.  
  95. FindScreen 0  ;I think we'll need one of these  ;)
  96.  
  97. Window 0,0,0,1,1,0,"",0,0   ;invisible window for the requesters
  98.  
  99. answer.b=RTEZRequest (ourname$,"Save library information?","To Disk|Printer|  No!  ",2,1,4)
  100. If answer=2
  101.   Windo$="CON:160/20/320/40/Printer Check/SCREENSuperTED1/NOSIZE"
  102. EndIf
  103. wind.l=OpenFile (1,Windo$)
  104. If wind = 0
  105.   Request "ERROR!","Can't open console window","AAAARRRGGGGHHHH!"
  106.   End
  107. EndIf
  108. FileOutput 1     ;output to the console window
  109.  
  110. Select answer
  111.   Case 1         ;save to disk
  112.     savepath$=RTEZPathRequest ("Save data files to:")
  113.     tofile.b=1
  114.  
  115.   Case 2         ;the printer
  116.     answer=RTEZRequest(ourname$,"Is your printer ready?","Get on with it!")
  117.     If OpenFile(3,"PRT:")
  118.       NPrint "Waiting on the printer..."
  119.       FileOutput 3
  120.       NPrint " "
  121.       NPrint "Blitz library information:"
  122.       NPrint " "
  123.       CloseFile 1
  124.       printer.b=1
  125.       cxl$="Cancel Printing"
  126.     EndIf
  127. End Select
  128.  
  129. DosBuffLen 2048          ;we need 'em for the disk files...
  130.  
  131. Format "000"
  132. Repeat
  133. notBlitz.b=1
  134. biglib.b=0
  135. lyne$="_______________________________________________"
  136. If printer=0 Then lyne$="-----------------------------------"
  137. NPrint lyne$
  138. NPrint " "
  139. ; ------- we need file(s) to read! ----------------------------
  140.  
  141. selected.l=RTEZMultiLoadFile(" Select Libraries to scan:")
  142. lib$=RTNextPathEntry
  143. If lib$="" Then Goto quit   ;nothing selected - ie, CANCEL
  144.  
  145. ; ------- panic button ----------------------------------------
  146.  
  147. chekrq.l=RTASyncRequest(" Panic Button",cxl$,"Enough!")
  148. dumpit.b=0
  149.  
  150. While lib$<>"" AND dumpit=0      ;OK, read 'em all...
  151.   NPrint lyne$
  152.   NPrint " "
  153.   For i = Len(lib$) To 1 Step-1  ;pull out the file name
  154.     check$=Mid$(lib$,i,1)
  155.     If check$="/" OR check$=":"
  156.       source$=Mid$(lib$,i+1)
  157.       path$=Left$(lib$,i)
  158.       i=1
  159.     EndIf
  160.   Next
  161.   ;EndIf
  162.   source$=UCase$(source$)
  163.   If source$="DEFLIBS" OR source$="ACIDLIBS" Then biglib=1
  164.  
  165.   ;If lib$=""Then Goto quit
  166.  
  167.   If ReadFile(0,lib$)   ;make sure it's a Blitz library!
  168.     FileInput 0
  169.     check$=Inkey$(4)
  170.     If check$=ok$
  171.        notBlitz=0
  172.     Else
  173.       check$=Inkey$(4)
  174.       If check$= ok$ Then notBlitz=0
  175.     EndIf
  176.     If notBlitz=0
  177.       check$=Inkey$(20)
  178.       check$=Inkey$(4)
  179.       If check$<>ok1$ Then notBlitz=1
  180.     EndIf
  181.  
  182.     If notBlitz
  183.       rq$=source$+z$+"is not a Blitz library!"
  184.       dummy.b=RTEZRequest (ourname$,rq$,"OK")
  185.     Else
  186.       check$=Inkey$(4)   ;throw away the next 4 bytes
  187.       a$=Inkey$(1)
  188.       If a$="p"          ;ah, a standard Blitz lib
  189.         syslib.b=0
  190.       Else               ;no, must be an Amigalib
  191.         syslib=1
  192.       EndIf
  193.     ; -- ok, now get the library number ---------------------------
  194.  
  195.       Select syslib       ;system libraries are a bit different...
  196.  
  197.         Case 0            ;a Blitz style library (maybe deflibs or acidlibs)
  198.           FileSeek 0,28
  199.           While NOT Eof(0) AND dumpit=0
  200.               a.b=Asc(Inkey$(1))
  201.               If a=$70
  202.                 a$=(Inkey$(4))
  203.                 If a$=ok2$
  204.                   a=Asc(Inkey$(1))
  205.                   If a<>0
  206.                     libnum.w=a AND $FF
  207.                     Gosub ReadEm
  208.                     If cmdnum.w>0 AND biglib=1
  209.                       NPrint lyne$
  210.                       NPrint " "
  211.                     EndIf
  212.                   EndIf
  213.                 EndIf
  214.               EndIf
  215.             If dumpit=0
  216.               chekrq.l=RTCheckASyncRequest
  217.               If chekrq= 0
  218.                 dumpit=1
  219.                 Pop While:Pop Select
  220.                 Goto dumped
  221.               EndIf
  222.             EndIf
  223.           Wend
  224.  
  225.         Case 1            ;for system libs
  226.           FileSeek 0,37
  227.           a.b=Asc(Inkey$(1))
  228.           libnum.w= a AND $FF
  229.           NPrint " ",source$," Lib# ",libnum
  230.           NPrint " "
  231.           Gosub SysRead
  232.       End Select
  233.  
  234.     EndIf
  235.     dumped
  236.     CloseFile 0
  237.     PopInput
  238.   EndIf
  239.   If dumpit=0
  240.     chekrq.l=RTCheckASyncRequest
  241.     If chekrq=0
  242.       lib$=""
  243.       dumpit=1
  244.     Else
  245.       lib$=RTNextPathEntry
  246.     EndIf
  247.   Else
  248.     lib$=""
  249.   EndIf
  250.   If lib$<>"" AND printer=0 Then VWait 100
  251. Wend
  252. If dumpit=0
  253.   RTEndASyncRequest
  254. EndIf
  255.  
  256. RTEZSetDefaultDirectory 3,path$
  257. Forever
  258.  
  259. ReadEm        ;read the command names
  260. ;look for $FFFF0000 000000 00
  261.  
  262.  
  263. done.b=0
  264. firstcmd.b=0
  265. cmdnum.w=0
  266. Repeat
  267.   b.w=Asc(Inkey$(1))
  268.   If b=255
  269.     b.w=Asc(Inkey$(1))
  270.     If b=255                 ;aha, two $FF's !
  271.       For i = 1 To 6         ;now the 6 $00's ?
  272.         b=Asc(Inkey$(1))
  273.         If b<>0 Then done=1  ;nope, must be the end of the command list!
  274.       Next
  275.       If done = 0
  276.         gotall.b=0
  277.         cmd$=""
  278.         a$=Inkey$(1)
  279.         If a$ = Chr$(0)      ;another $00?
  280.           done=1
  281.         Else
  282.           If firstcmd=0      ;first command found!
  283.             NPrint source$," Lib# ",libnum
  284.             NPrint " "
  285.             If tofile        ;this bit saves to disk file
  286.               Format ""
  287.               outpath$=savepath$+"Blib."+Str$(libnum)
  288.               Format "000"
  289.               If OpenFile(4,outpath$)=0
  290.                 tofile=0
  291.                 dummy.b= RTEZRequest (ourname$,"can't open output file!","OK")
  292.               Else
  293.                 FileOutput 4
  294.                 NPrint source$
  295.                 FileOutput 1
  296.               EndIf
  297.             EndIf
  298.             firstcmd=1
  299.           EndIf
  300.           cmd$+a$
  301.         EndIf
  302.         If done=0       ;here we read the actual command string
  303.           cmdnum+1
  304.           Repeat
  305.             a$=Inkey$(1)
  306.             If a$>Chr$(35) AND a$<Chr$(126)
  307.               cmd$+a$
  308.             Else
  309.               gotall=1
  310.             EndIf
  311.           Until gotall
  312.           NPrint " ",Str$(cmdnum),"  ",cmd$
  313.           If tofile
  314.             FileOutput 4
  315.             NPrint cmd$
  316.             FileOutput 1
  317.           EndIf
  318.         EndIf
  319.       EndIf
  320.     EndIf
  321.   EndIf
  322. Until done
  323. CloseFile 4
  324.  
  325. ;If cmdnum>1
  326.   ;NPrint "-> ",Str$(cmdnum)," commands"
  327. ;EndIf
  328.  
  329. NPrint " "
  330. If biglib=1 AND cmdnum>0 AND tofile=0 Then VWait 100
  331. Return
  332.  
  333.  
  334. SysRead
  335.  
  336. ; look for  $FF0000 000000 00
  337. ;     or    $FF0000 000000 0000  in amigalibs!
  338.  
  339. cmdnum=0
  340. done=0
  341. If tofile        ;save to disk
  342.   Format ""
  343.   If OpenFile(4,savepath$+"Blib."+Str$(libnum))=0
  344.     tofile=0
  345.     dummy.b= RTEZRequest (ourname$,"can't open output file!","OK")
  346.   Else
  347.     FileOutput 4
  348.     NPrint source$
  349.     FileOutput 1
  350.   EndIf
  351.   Format "000"
  352. EndIf
  353.  
  354. Repeat
  355.   b.w=Asc(Inkey$(1))
  356.   If b=255              ;now look for 6 or 7 0's
  357.     b.w=Asc(Inkey$(1))
  358.     If b=255            ;in system libs, $FFFF means end of command list
  359.       b=Asc(Inkey$(1))
  360.       If b=0
  361.         done=1
  362.       EndIf
  363.     Else
  364.       If b=0            ;OK, now check for at least 6 $00's
  365.         gonext.b=0
  366.         For i = 1 To 5
  367.           b=Asc(Inkey$(1))
  368.           If b<>0 Then gonext.b=1
  369.         Next
  370.         If gonext=0
  371.           gotall.b=0
  372.           cmdnum+1
  373.           cmd$=""
  374.           a$=Inkey$(1)
  375.           If a$ = Chr$(0)  ;sometimes there is one more $00
  376.             a$=Inkey$(1)
  377.           EndIf
  378.           cmd$+a$          ;now we read the command string
  379.           Repeat
  380.             a$=Inkey$(1)
  381.             If a$>Chr$(35) AND a$<Chr$(126) ;alphabetic character?
  382.               cmd$+a$
  383.             Else
  384.               gotall=1
  385.             EndIf
  386.           Until gotall
  387.           NPrint " ",Str$(cmdnum)," ",cmd$
  388.           If tofile
  389.             FileOutput 4   ;to the disk file
  390.             NPrint cmd$
  391.             FileOutput 1   ;back to the console
  392.           EndIf
  393.         EndIf
  394.       EndIf
  395.     EndIf
  396.   EndIf
  397. Until done
  398. CloseFile 4
  399. Return
  400.  
  401. quit
  402.  
  403. CloseFile 1
  404. CloseFile 3
  405. CloseFile 4
  406. End
  407.  
  408.  
  409.